require "Task/DailyTask/DailyTaskBase"

QNW_TS_Fitness = QNW_TS_DailyTaskBase:derive("QNW_TS_Fitness")

local this = QNW_TS_Fitness
this.name = getText("IGUI_QNW_TaskSystem_Task_Fitness_Name")
this.desc = getText("IGUI_QNW_TaskSystem_Task_Fitness_Desc")

function QNW_TS_Fitness:getProgress()
    local count = math.min(self.count, self.maxCount)
    return tostring(math.floor(count / 1000 / 60)) .. "/" .. math.floor(self.maxCount / 1000 / 60)
end

function QNW_TS_Fitness:new()
    local o = QNW_TS_DailyTaskBase:new()
    setmetatable(o, self)
    self.__index = self

    o.maxCount = 90 * 60 * 1000

    return o
end

function QNW_TS_Fitness:initReward()
    local player = getPlayer()
    local level1 = player:getPerkLevel(Perks.Fitness)
    local level2 = player:getPerkLevel(Perks.Strength)
    if level1 == 10 and level2 == 10 then
        QNW_TS_ClientCommand.randomReward(self, "medium", 2)
    else
        if ZombRand(4) == 0 then
            QNW_TS_ClientCommand.randomReward(self, "low", 2)
        else
            table.insert(self.rewards, QNW_TS_PerkXpReward:new("Fitness", 10000))
            table.insert(self.rewards, QNW_TS_PerkXpReward:new("Strength", 10000))
        end
    end
end
